

package com.hazelcast.collection.impl.queue.model;

import java.util.Comparator;

public class PriorityElementComparator implements Comparator<PriorityElement> {
    @Override
    public int compare(PriorityElement o1, PriorityElement o2) {
        if (o1.isHighPriority() && !o2.isHighPriority()) {
            return -1;
        }
        if (o2.isHighPriority() && !o1.isHighPriority()) {
            return 1;
        }
        return Integer.compare(o1.getVersion(), o2.getVersion());
    }
}
